public class Main {
    static class Solution{
        public boolean canJump(int[] nums) {
            int food = 0;
            int i;
            for (i = 0; i < nums.length; i++) {

                if (--food < nums[i]) {
                    food = nums[i];
                }
                if (food == 0)
                    break;
            }
            return i >= nums.length - 1;
        }
    }

    public static void main(String[] args) {
        Solution solution = new Solution();
        boolean result = solution.canJump(new int[]{3,4,1,0,4});
        System.out.println(result);
    }
}